package com.eightbears.beboy.adapter;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.entity.WaitPaymentEntity;
import com.makeramen.roundedimageview.RoundedImageView;

public class WaitPaymentAdapter extends BaseQuickAdapter<WaitPaymentEntity.WaitPayment, BaseViewHolder> {

    private LinearLayout ll_valid_date;
    private TextView tv_right_text;


    public WaitPaymentAdapter() {
        super(R.layout.item_order, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, WaitPaymentEntity.WaitPayment waitPayment) {
        ll_valid_date = baseViewHolder.getView(R.id.ll_valid_date);
        tv_right_text = baseViewHolder.getView(R.id.tv_right_text);
        Glide.with(mContext).load(waitPayment.getObject().getCover()).crossFade().error(R.mipmap.default_icon).
                into((RoundedImageView) baseViewHolder.getView(R.id.iv_shopbook_image));
        replaceView();
        baseViewHolder.setText(R.id.tv_shopbook_mealname, waitPayment.getObject().getTitle())
                .setText(R.id.iv_shopbook_left, waitPayment.getObject().getShop().getTitle())
                .setText(R.id.tv_shopbook_mealprice, "￥" + waitPayment.getTotal_amount())
                .setText(R.id.tv_shopbook_mealoldprice, "订单金额:￥" + waitPayment.getTotal_amount())
                .setText(R.id.tv_shopbook_mealbug, "付款")
                .addOnClickListener(R.id.tv_shopbook_mealbug)
                .addOnClickListener(R.id.shop_info_meal);

    }

    private void replaceView() {
        ll_valid_date.setVisibility(View.GONE);
        tv_right_text.setVisibility(View.VISIBLE);
    }
}
